
-- Botao de Interatividade
local img = canvas:new('buttons/botaoI.png')
local dx, dy = img:attrSize()
local btInteratividade = { img=img, x=950, y=10, dx=dx, dy=dy }

local img = canvas:new('buttons/1_red.png')
local dx, dy = img:attrSize()
local btOpcao1 = { img=img, x=5, y=210, dx=dx, dy=dy }

local img = canvas:new('buttons/2_red.png')
local dx, dy = img:attrSize()
local btOpcao2 = { img=img, x=5, y=110, dx=dx, dy=dy }

local img = canvas:new('buttons/3_red.png')
local dx, dy = img:attrSize()
local btOpcao3 = { img=img, x=5, y=10, dx=dx, dy=dy }

function desenha_menu ()
	--canvas:clear()
	canvas:compose(btOpcao1.x, btOpcao1.y, btOpcao1.img)
	canvas:compose(btOpcao2.x, btOpcao2.y, btOpcao2.img)
	canvas:compose(btOpcao3.x, btOpcao3.y, btOpcao3.img)
	canvas:flush()
end

function apaga_menu ()
	--canvas:clear()
	canvas:compose(btInteratividade.x, btInteratividade.y, btInteratividade.img)
	canvas:flush()
end

-- Funcao de tratamento de eventos:
function handler (evt)
	print("=================================")
	for k,v in pairs(evt) do print(k,v) end
	print("=================================")

	if evt.class == 'ncl' and evt.type == 'presentation' and evt.action == 'start' then
		print "Vai desenhar!!"
		desenha_menu()
		print "Desenhou!!"
		
		print("=================================")
		print "Vai enviar stop!!"
		--evt['action'] = 'stop'
		--event.post( evt )
		print "Enviou!!!"
	end
	
	if evt.class == 'key' and evt.type == 'press' then
		if evt.key == 'GREEN' then
			evt_send = { class = 'ncl', type = 'presentation', action = 'stop', }
			event.post(evt_send)
		end
	end
end

--apaga_menu()
event.register(handler)
